#include<iostream> #include<string> usingnamespace std; intcountnumber(string s){ int n = s.size(); int num=0; for (int i = 0;i < n;i++) { int left = i; int right = i;
while (left >= 0 && right < n && s[left] == s[right]) { num++; --left; ++right; } left = i, right = i + 1; while (left >= 0 && right < n && s[left] == s[right]) { num++; --left; ++right; } } return num; } intmain(){ string s; while (cin >> s) { cout << countnumber(s) << endl; } return0; }
voidpredictNext(int a, int b, int c, int d, int e){ if (a == 0 && b == 0 && c == 0 && d == 0 && e == 0) return;
int d = b - a; if (b + d == c && c + d == d && d + d == e) { cout << e + d << " " << e + 2 * d << " " << e + 3 * d << " " << e + 4 * d << " " << e + 5 * d << endl; return; }
if (a != 0 && b != 0 && c != 0 && d != 0 && e != 0) { int q = b / a; if (a * q == b && b * q == c && c * q == d && d * q == e) { int next = e; for (int i = 0; i < 5; ++i) { next *= q; cout << next << " "; } cout << endl; return; } }
if (a + b == c && b + c == d && c + d == e) { int x = d, y = e; for (int i = 0; i < 5; ++i) { int z = x + y; cout << z << " "; x = y; y = z; } cout << endl; return; }
int x = d, y = e; for (int i = 0; i < 5; ++i) { int z = x + y; cout << z << " "; x = y; y = z; } cout << endl; }
intmain(){ int a, b, c, d, e; while (cin >> a >> b >> c >> d >> e) { if (a == 0 && b == 0 && c == 0 && d == 0 && e == 0) break; predictNext(a, b, c, d, e); } return0; }
while (!q.empty()) { auto [x, y] = q.front(); q.pop();
if (x == end.first && y == end.second) return dist[x][y];
for (int i = 0; i < 4; i++) { int nx = x + dx[i], ny = y + dy[i]; if (nx >= 0 && nx < n && ny >= 0 && ny < m && grid[nx][ny] != '#' && dist[nx][ny] == -1) { dist[nx][ny] = dist[x][y] + 1; q.push({nx, ny}); } } } return-1; }
int T; cin >> T; while (T--) { cin >> n >> m; pair<int, int> start, end; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> grid[i][j]; if (grid[i][j] == 'S') start = {i, j}; if (grid[i][j] == 'E') end = {i, j}; } }